<template>
  <el-container>
    <el-header height="90px" style="background: rgb(59,90,121)">
      <div style="height: 80px;width: 200px;margin-top: 2px" >
        <img src="static/img/logo.png" width="100%" height="100%">
      </div>
      <div class="demo-basic--circle" style="position: absolute;right: 50px;top: 20px">
        <div class="block"><el-avatar :size="60">Admin</el-avatar></div>
      </div>
    </el-header>
    <el-container style="height: 900px">
      <el-aside width="200px" style="background: rgb(59,90,121)">
        <el-row class="tac">
          <el-col>
            <el-menu
              :default-active="index"
              class="el-menu-vertical-demo"
              @open="handleOpen"
              @close="handleClose"
              @select="handleSelect"
              background-color="rgb(59,90,121)"
              text-color="#fff"
              active-text-color="#ffd04b">
              <el-menu-item index="1" >
                <i class="el-icon-s-custom" ></i>
                <span slot="title">首页</span>
              </el-menu-item>
              <el-menu-item index="2" >
                <i class="el-icon-view" ></i>
                <span slot="title">全部文件</span>
              </el-menu-item>
              <el-menu-item index="3">
                <i class="el-icon-picture"></i>
                <span slot="title">图片</span>
              </el-menu-item>
              <el-menu-item index="4">
                <i class="el-icon-video-camera-solid"></i>
                <span slot="title">视频</span>
              </el-menu-item>
              <el-menu-item index="5">
                <i class="el-icon-document"></i>
                <span slot="title">文档文件</span>
              </el-menu-item>
              <el-menu-item index="6">
                <i class="el-icon-s-promotion"></i>
                <span slot="title">其他文件</span>
              </el-menu-item>
              <el-menu-item @click="loginOut">
                <i class="el-icon-switch-button"></i>
                <span slot="title">退出登录</span>
              </el-menu-item>
            </el-menu>
          </el-col>
        </el-row>


      </el-aside>
      <el-main>
        <router-view></router-view>
      </el-main>
    </el-container>
  </el-container>

</template>
<script src="/config/serverip.js"></script>
<script>
import global from "./global";
import axios from "axios";
export default {
name: "manager",
  data(){
  return{
    paths:["/manager/info","/manager/main","/manager/main?type=png","/manager/main?type=video","/manager/main?type=txt","/manager/main?type=order"],
    index:"1",
    serverAdress:global.serverAdress,
    token: "",
  }
  },
  methods: {
    loginOut(){
      this.$confirm('此操作将退出管理后台, 是否继续?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        sessionStorage.clear();
        this.$router.push("/");
        localStorage.clear();
        this.$message({
          type: 'success',
          message: '退出成功!'
        });

      }).catch(() => {
        this.$message({
          type: 'info',
          message: '取消退出'
        });
      });

    },
    getIndex(){
      let path=this.$route.path;
     if(path=="/manager/user"){
       this.index="1";
     }else if(path=="/manager/movie"){
       this.index="2";
     }else if(path=="/manager/product"){
       this.index="3";
     }else if(path=="/manager/orders"){
       this.index="4";
     }else if(path=="/manager/admin"){
       this.index="5";
     }else if(path=="/manager/files"){
       this.index="6";
     }else if(path=="/manager/face"){
       this.index="7";
     }
    },
    handleOpen(key, keyPath) {
      console.log(key, keyPath);
    },
    handleClose(key, keyPath) {
      console.log(key, keyPath);
    },
    handleSelect(key,keyPath){
      this.$router.push({path:this.paths[key-1]});
    },
    getAuthority(){
      let _this=this;
      this.$http.get(this.serverAdress+"/admin/getAuthority",{headers:{"token":this.token}})
        .then(function (ret){
          if(!ret.data.state){
            _this.$refs.admins.$el.style.display="none";
        }
      })
    },

  },
  mounted() {
    axios.defaults.headers.token = localStorage.getItem("token");
  },
  created() {
  // let item = sessionStorage.getItem("token");
  // if(item!=null){
  //   this.token=item;
  // }else {
  //   sessionStorage.clear();
  //   this.$router.push("/");
  // }
  //   this.getIndex();
  //   this.getAuthority();
  // },
  // beforeRouteEnter(to,from,next){
  //   window.document.body.style.backgroundColor="";
  //   next();
   }
}

</script>

<style scoped>

</style>
